﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
	//Thank you Toan :)
    }

    protected void Button1_Click1(object sender, EventArgs e)
    {
        TxtKq.Text = TxtKq.Text + "1";
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        TxtKq.Text = TxtKq.Text + "2";
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        TxtKq.Text = TxtKq.Text + "3";
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        TxtKq.Text = TxtKq.Text + "4";
    }
    protected void Button5_Click(object sender, EventArgs e)
    {
        TxtKq.Text = TxtKq.Text + "5";
    }
    protected void Button6_Click(object sender, EventArgs e)
    {
        TxtKq.Text = TxtKq.Text + "6";
    }
    protected void Button7_Click(object sender, EventArgs e)
    {
        TxtKq.Text = TxtKq.Text + "7";
    }
    protected void Button8_Click(object sender, EventArgs e)
    {
        TxtKq.Text = TxtKq.Text + "8";
    }
    protected void Button9_Click(object sender, EventArgs e)
    {
        TxtKq.Text = TxtKq.Text + "9";
    }
    protected void Button10_Click(object sender, EventArgs e)
    {
        TxtKq.Text = TxtKq.Text + "0";
    }
    protected void Cham_Click(object sender, EventArgs e)
    {
        TxtKq.Text = TxtKq.Text + ".";
    }
    protected void CongTru_Click(object sender, EventArgs e)
    {
        TxtKq.Text = "+" + TxtKq.Text;
    }
    Double x1 =0;
    Double x2 = 0;
    Double x3 = 0;
    int phepTinh = 0;
    protected void Cong_Click(object sender, EventArgs e)
    {
        //Double x1;
        x1 = Convert.ToDouble(TxtKq.Text);
        TxtKq.Text = "";
       
        phepTinh = 1;
    }

    protected void Tru_Click(object sender, EventArgs e)
    {
        x1 = Convert.ToDouble(TxtKq.Text);
        TxtKq.Text = "";
     
        phepTinh = 2;
    }
    protected void Nhan_Click(object sender, EventArgs e)
    {
        x1 = Convert.ToDouble(TxtKq.Text);
        TxtKq.Text = "";
     
        phepTinh = 3;
    }
    protected void Chia_Click(object sender, EventArgs e)
    {
        x1 = Convert.ToDouble(TxtKq.Text);
        TxtKq.Text = "";
       
        phepTinh = 4;
    }
    protected void Bang_Click(object sender, EventArgs e)
    {
        x2 = Convert.ToDouble(TxtKq.Text);
        if (phepTinh == 1)
        {
            x3 = x1 + x2;
        }
        if (phepTinh == 2)
        {
            x3 = x1 - x2;
        }
        if (phepTinh == 3)
        {
            x3 = x1 * x2;
        }
        if (phepTinh == 4)
        {
            x3 = x1 / x2;
        }
        TxtKq.Text = x3.ToString();
    }
}